package com.cyj.springbootservice.service.impl;


import com.cyj.springbootservice.service.RedisLockService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.klock.annotation.Klock;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @Author C_Y_J
 * @create 2022/5/6 15:33
 **/
@Slf4j
@Service
public class RedisLockServiceImpl implements RedisLockService {

    @Klock(keys = {"#userName"})
    @SneakyThrows
    @Override
    public String list(String userName) {
        log.info("{}进入list方法，成功获取锁", userName);

        Thread.sleep(5 * 1000);

        log.info("{}执行完毕list方法，成功释放锁", userName);

        return userName + "执行完毕list方法";
    }
}
